package com.gm.wholesale.module.order.adapter;
import android.os.Parcelable;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentStatePagerAdapter;
import com.gm.commonlib.base.baseBean.BaseFragmentInfo;
import com.youth.banner.util.LogUtils;

import java.util.List;
public class ViewPagerAdapter extends FragmentStatePagerAdapter {
    private List<BaseFragmentInfo> mFragments;

    @Nullable
    @Override
    public Parcelable saveState() {
        return null;
    }

    public ViewPagerAdapter(FragmentManager fm, List<BaseFragmentInfo> fragments) {
        super(fm);
        mFragments = fragments;
    }
    @Override
    public Fragment getItem(int position) {
        try {
            Fragment fragment1 = mFragments.get(position).getFragment();
            return fragment1;

        } catch (Exception e) {
            LogUtils.d("eeeeeeeeeeeeee； " + e.toString());
        }
        return null;
    }

    @Override
    public int getCount() {
        return mFragments.size();
    }

    @Nullable
    @Override
    public CharSequence getPageTitle(int position) {
        return mFragments.get(position).getTitle();
    }
}
